FileChooserWidget: Avoid crash freeing static str
authorDaniel Boles <dboles@src.gnome.org>
Mon, 12 Mar 2018 22:44:37 +0000 (22:44 +0000)
committerDaniel Boles <dboles@src.gnome.org>
Mon, 12 Mar 2018 23:07:50 +0000 (23:07 +0000)
Having a FileChooserDialog in location-entry mode then pressing
<primary>f to move to search mode would crash with an invalid free().

In that case, FileChooserWidget.get_subtitle() returned a static string
straight from gettext. This crashed when the GBinding from :subtitle to
FileChooserDialog’s HeaderBar:subtitle shortly tried to free the string.

Fix by duplicating the string before returning it, like all other paths.

https://bugzilla.gnome.org/show_bug.cgi?id=791004

gtk/gtkfilechooserwidget.c

index 0d6132c020a46ec17788ebeac0d432a75959815c..e94de516bd9081d9341aaf1b5a364627565a4f79 100644 (file)
@@ -3198,7 +3198,7 @@ gtk_file_chooser_widget_get_subtitle (GtkFileChooserWidget *impl)
     {
       gchar *location;
 
-      subtitle = _("Searching");
+      subtitle = g_strdup (_("Searching"));
 
       location = gtk_places_sidebar_get_location_title (GTK_PLACES_SIDEBAR (priv->places_sidebar));
       if (location)